<?php

namespace app\api\controller\login;

use app\api\controller\Member;
use app\common\model\BannerModel;
use app\common\model\AssociationModel;
use app\common\model\NoticeModel;

class School extends Member
{
    /**
     * 获取轮播图列表
     */
    public function getBanner(){
        $user = $this->getMember();
        $banner = BannerModel::where('status',1)
            ->where('school_id',$user['school_id'])
            ->order('sort asc,id desc')
            ->select();
        if (!empty($banner)) {
            $this->success('获取轮播图列表成功！', $banner, 200);
        } else {
            $this->error('获取轮播图列表失败！', '', 400);
        }
    }

    /**
     * 获取公告通知
     */
    public function getNotice(){
        $user = $this->getMember();
        $notice = NoticeModel::where('status',1)
            ->where('school_id',$user['school_id'])
            ->order('sort asc,id desc')
            ->select();
        if (!empty($notice)) {
            $this->success('获取公告通知列表成功！', $notice, 200);
        } else {
            $this->error('获取公告通知列表失败！', '', 400);
        }
    }
    
    /**
     * 获取社团文化
     */
    public function getAssociation(){
        $user = $this->getMember();
        $association = AssociationModel::where('status',1)
            ->where('school_id',$user['school_id'])
            ->order('sort asc,id desc')
            ->limit(4)
            ->select();
        if (!empty($association)) {
            $this->success('获取社团文化列表成功！', $association, 200);
        } else {
            $this->error('获取社团文化列表失败！', '', 400);
        }
    }

}
